package com.zkthink.ceres.applet.order.controller;

import com.zkthink.base.R;
import com.zkthink.ceres.pay.dto.WxAuthAccountDTO;
import com.zkthink.ceres.pay.dto.WxAuthQrCodeDTO;
import com.zkthink.ceres.pay.dto.WxAuthStatusDTO;
import com.zkthink.ceres.pay.dto.WxPayAuthSaveDTO;
import com.zkthink.ceres.pay.entity.WxPayAuth;
import com.zkthink.ceres.pay.service.WxPayAuthService;
import com.zkthink.dozer.DozerUtils;
import com.zkthink.log.annotation.SysLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


/**
 * <p>
 * 前端控制器
 * 微信支付认证
 * </p>
 *
 * @author vivi.huang
 * @date 2020-06-28
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/wxPayAuth")
@Api(value = "WxPayAuth", tags = "微信支付认证")
@AllArgsConstructor
//@PreAuth(replace = "wxPayAuth:")
public class WxPayAuthController {

    private WxPayAuthService wxPayAuthService;
    private DozerUtils dozerUtils;


    /**
     * 查询维系支付认证详情
     *
     * @return 查询结果
     */
    @ApiOperation(value = "查询微信支付认证详情", notes = "查询维系支付认证详情")
    @GetMapping("/detail")
    @SysLog("'查询维系支付认证详情:'")
//    @PreAuth("hasPermit('{}view')")
    public R<WxPayAuth> getWxPayAuthDetail() {
        return wxPayAuthService.getWxPayAuthDetail();
    }

    /**
     * 提交认证信息
     * @return 实体
     */
    @ApiOperation(value = "提交认证信息")
    @PostMapping
    @SysLog(value = "提交认证信息", request = false)
//    @PreAuth("hasPermit('{}add')")
    public R<WxPayAuth> submitAuthData(@RequestBody @Validated WxPayAuthSaveDTO wxPayAuthSaveDTO) {
        return wxPayAuthService.submitPayAuth(wxPayAuthSaveDTO);
    }


    /**
     * 返回签约二维码
     *
     * @return 返回签约二维码
     */
    @ApiOperation(value = "返回签约二维码", notes = "返回签约二维码")
    @GetMapping("/qrcode")
    @SysLog("'返回签约二维码:'")
//    @PreAuth("hasPermit('{}view')")
    public R<WxAuthQrCodeDTO> getWxPayAuthQrCode() {
        return wxPayAuthService.getWxPayAuthQrCode();
    }

    /**
     * 店铺认证状态
     *
     * @return 店铺认证状态
     */
    @ApiOperation(value = "店铺认证状态", notes = "店铺认证状态")
    @GetMapping("/status")
    @SysLog("'店铺认证状态:'")
//    @PreAuth("hasPermit('{}view')")
    public R<WxAuthStatusDTO> getWxPayAuthStatus() {
        return wxPayAuthService.getWxPayAuthStatus();
    }

    /**
     * 查询账户认证详情
     *
     * @return 店铺认证状态
     */
    @ApiOperation(value = "查询账户认证详情", notes = "查询账户认证详情")
    @GetMapping("/account")
    @SysLog("'查询账户认证详情:'")
//    @PreAuth("hasPermit('{}view')")
    public R<WxAuthAccountDTO> getWxAuthAccountDetail() {
        return wxPayAuthService.getWxAuthAccountDetail();
    }

    /**
     * 检验账户认证状态
     *
     * @return 店铺认证状态
     */
    @ApiOperation(value = "检验账户认证状态", notes = "检验账户认证状态")
    @GetMapping("/account/status")
    @SysLog("'检验账户认证状态:'")
//    @PreAuth("hasPermit('{}view')")
    public R<WxAuthAccountDTO> getWxAuthAccountStatus() {
        return wxPayAuthService.getWxAuthAccountStatus();
    }

}
